from dataclasses import dataclass
from typing import Dict, List, Optional


@dataclass
class AIModelConfig:
    """AI模型配置类"""
    name: str
    api_base: str
    api_key: str
    model: str
    additional_params: Optional[Dict] = None
    
    def get_auth_headers(self) -> Dict[str, str]:
        """获取认证头"""
        return {"Authorization": f"Bearer {self.api_key}"}
    
    def build_payload(self, messages: List[Dict], stream: bool) -> Dict:
        """构造请求体"""
        payload = {
            "model": self.model,
            "messages": messages,
            "temperature": 0.7,
            "stream": stream
        }
        if self.additional_params:
            payload.update(self.additional_params)
        return payload
